package com.manong.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.manong.dao.OrderMapper;
import com.manong.dao.SupMapper;
import com.manong.entity.Order;
import com.manong.entity.Sup;
import com.manong.service.OrderService;
import com.manong.service.SupService;
import com.manong.vo.query.SupVo;
import org.springframework.stereotype.Service;

@Service
public class SupServiceImpl extends ServiceImpl<SupMapper, Sup> implements SupService {
    @Override
    public IPage<Sup> findSupListByUsername(IPage<Sup> page, SupVo supVo) {
        QueryWrapper<Sup> queryWrapper = new QueryWrapper<Sup>();
        queryWrapper.like(!ObjectUtils.isEmpty(supVo.getName()),"name",supVo.getName())
                .like(!ObjectUtils.isEmpty(supVo.getPhone()),"phone",supVo.getPhone())
                .like(!ObjectUtils.isEmpty(supVo.getContact()),"contact",supVo.getContact());
        return baseMapper.selectPage(page,queryWrapper);
    }

    @Override
    public boolean deleteById(Long id) {
        return baseMapper.deleteById(id)>0;
    }
}
